#include <iostream>
#include <vector>
using namespace std;

const int MAXN = 524288;
int n, q;
vector<int> a(MAXN, 0);
vector<int> tree(4 * MAXN, 0);

void build(int node, int start, int end) {
    if (start == end) {
        tree[node] = a[start];
    } else {
        int mid = (start + end) / 2;
        build(2 * node, start, mid);
        build(2 * node + 1, mid + 1, end);
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}

void update(int node, int start, int end, int idx, int val) {
    if (start == end) {
        a[idx] = val;
        tree[node] = val;
    } else {
        int mid = (start + end) / 2;
        if (start <= idx && idx <= mid) {
            update(2 * node, start, mid, idx, val);
        } else {
            update(2 * node + 1, mid + 1, end, idx, val);
        }
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}

int query(int node, int start, int end, int l, int r) {
    if (r < start || end < l) {
        return 0;
    }
    if (l <= start && end <= r) {
        return tree[node];
    }
    int mid = (start + end) / 2;
    int p1 = query(2 * node, start, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, end, l, r);
    return p1 + p2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    build(1, 0, n - 1);

    while (q--) {
        int op, i, X, v;
        cin >> op;
        if (op == 1) {
            cin >> i >> v;
            update(1, 0, n - 1, i, v);
        } else if (op == 2) {
            cin >> i >> X;
            int sum = 0;
            for (int j = 0; j <= X; ++j) {
                int idx = i ^ j;
                if (idx < n) {
                    sum += query(1, 0, n - 1, idx, idx);
                }
            }
            cout << sum << '\n';
        }
    }

    return 0;
}
